<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" />
    <title>奖励惩罚</title>
    <link rel="stylesheet" href="/addons/jquery-weui-build/css/weui.min.css">
    <link rel="stylesheet" href="/addons/jquery-weui-build/css/jquery-weui.css">
    <link rel="stylesheet" href="/css/system/main.css?v=2018050801">
</head>
<body ontouchstart>
<div class="mess-center award-pub">
    <div class="header-bk">
        <img class="con-head" src="../../images/system/ps1.png">
        <p class="p-center">奖励惩罚</p>
        <a class="add-tip a" href="javascript:void(0)"><img src="../../images/system/add-tip.png"></a>
        @if($us->is_leader == '1')
        <a class="add-tip" href="{{url('user/reward/verify-reward')}}">审核</a>
        @endif
    </div>
    <div class="min-con">
        <div class="input-form"><input type="text" placeholder="" value=""><i class="weui-icon-search"></i></div>
        <ul>
            @if(!empty($reward))
                @foreach($reward as $r)
                    @if($r->category == 2)
            <li>
                <img class="pull-left" src="../../images/system/punish.png">
                <a href="javascript:void(0)">
                    <div class="sec-block">
                        <div class="up">
                            <h3>提出惩罚<p class="p-time">{{$r->created_at->format('Y-m-d')}}</p></h3>
                        </div>
                        <div class="down">
                            <p class="title-p">
                                @if($uid == $r->from_user_id)
                                    你发出一条对{{getUserName($r->to_user_id)}}的惩罚
                                @else
                                    {{getUserName($r->from_user_id)}}发出一条对你的惩罚
                                @endif
                            </p>
                            <p>惩罚级别：{{$r->grade}}</p>
                            @if($r->is_effective == 1)
                                <span class="pass"></span>
                            @elseif($r->is_effective == 0)
                                <span class="wait"></span>
                            @else
                                <span class="error"></span>
                            @endif
                        </div>
                    </div>
                </a>
                <ul class="hidden">
                    @foreach(unserialize($r->detail) as $k=>$d)
                        @if($k%2==0)
                            <li><span class="circle-sp"></span><p>{{$d}}<span class="time-span"></span></p></li>
                        @else
                            <li><p>{{$d}}<span class="time-span"></span></p><span class="circle-sp"></span></li>
                        @endif
                    @endforeach
                    {{--<li><span class="circle-sp"></span><p>提出惩罚申请<span class="time-span">2018-04-18 17:25</span></p></li>
                    <li><p>组长1审核通过<span class="time-span">2018-04-18 17:25</span></p><span class="circle-sp"></span></li>
                    <li><span class="circle-sp"></span><p>组长2审核通过<span class="time-span">2018-04-18 17:25</span></p></li>
                    <li><p>组长3审核通过<span class="time-span">2018-04-18 17:25</span></p><span class="circle-sp"></span></li>
                    <li><span class="circle-sp"></span><p>惩罚通过<span class="time-span">2018-04-18 17:25</span></p></li>--}}
                </ul>
            </li>
                    @else
            <li>
                <img class="pull-left" src="../../images/system/reward.png">
                <a href="javascript:void(0)">
                    <div class="sec-block">
                        <div class="up">
                            <h3>提出奖励<p class="p-time">{{$r->created_at->format('Y-m-d')}}</p></h3>
                        </div>
                        <div class="down">
                            <p class="title-p">
                                @if($uid == $r->from_user_id)
                                    你发出一条对{{getUserName($r->to_user_id)}}的奖励
                                @else
                                    {{getUserName($r->from_user_id)}}发出一条对你的奖励
                                @endif
                            </p>
                            <p>奖励级别：{{$r->grade}}</p>
                            @if($r->is_effective == 1)
                                <span class="pass"></span>
                            @elseif($r->is_effective == 0)
                                <span class="wait"></span>
                            @else
                                <span class="error"></span>
                            @endif
                        </div>
                    </div>
                </a>
                <ul class="hidden">
                    @foreach(unserialize($r->detail) as $k=>$d)
                        @if($k%2==0)
                            <li><span class="circle-sp"></span><p>{{$d}}<span class="time-span">2018-04-18 17:25</span></p></li>
                        @else
                            <li><p>{{$d}}<span class="time-span">2018-04-18 17:25</span></p><span class="circle-sp"></span></li>
                        @endif
                    @endforeach
                </ul>
            </li>
                    @endif
                @endforeach
            @endif
        </ul>
    </div>
</div>
{{--添加奖励/惩罚--}}
<div class="award-hidden">
    <div class="popup"><h3>提出奖励/惩罚</h3><i class="weui-icon-cancel"></i></div>
    <form onsubmit="return false;">
        <a class="award-link kaohe_rp" data-id="1" href="javascript:void(0)"><span></span>奖励</a><input type="hidden" name="award" value="">
        <a class="pubnish-link kaohe_rp" data-id="2" href="javascript:void(0)"><span></span>惩罚</a><input type="hidden" name="pubnish" value="">
        <select class="" name="tuid">
            @foreach($user as $u)
                <option value="{{$u->id}}">{{$u->name}}</option>
            @endforeach
        </select>
        <select class="" name="class">
            @foreach($class as $k=>$u)
                <option value="{{$u}}">{{$k}}</option>
            @endforeach
        </select>
        <textarea name="reason"></textarea>
        <input type="hidden" name="_token" value="{{csrf_token()}}">
        <button class="sub-mit kh_submit">提交</button>
    </form>
</div>
{{--惩罚详情--}}
<div class="detail-pub">

</div>
<div class="show-hidden">
    <ul>
        <li><a href="{{url('/user/performance/detail')}}"><img src="../../images/system/user.png">我的考评</a></li>
        <li><a href="{{url('/user/performance/index')}}"><img src="../../images/system/all.png">全员考评</a></li>
        <li><a href="{{url('/user/performance/month')}}"><img src="../../images/system/message.png">月度意见</a></li>
    </ul>
</div>
<div class="reful-tabbar">
    <a href="javascript:void(0)" class="find-link tabbar-item ">
        <div class="img-div">
        </div>
        <p class="tabbar-label">考评</p>
    </a>
    <a href="{{url('/user/message')}}" class="message-center tabbar-item ">
        <div class="img-div">
        </div>
        <p class="tabbar-label">消息中心</p>
    </a>
    <a href="{{url('/user/reward')}}" class="reward-punishment tabbar-item active">
        <div class="img-div">
        </div>
        <p class="tabbar-label">奖励惩罚</p>
    </a>
    <a href="{{url('/user/setting')}}" class="set-up tabbar-item ">
        <div class="img-div">
        </div>
        <p class="tabbar-label">设置</p>
    </a>
</div>


<script src="/js/jquery-2.1.4.min.js"></script>
<script src="/addons/jquery-weui-build/js/fastclick.js"></script>
<script>
    $(function() {
        document.documentElement.style.fontSize = document.documentElement.clientWidth / 7.5 + 'px';
        FastClick.attach(document.body);
    });
</script>
<script src="/addons/jquery-weui-build/js/jquery-weui.min.js"></script>
<script>
    $(document).ready(function () {
        $('.find-link').click(function () {
            $('.show-hidden').toggle();
        });
        $('.add-tip.a').click(function () {
            $('.award-hidden').css('display','block');
        })
        $('.award-hidden .popup i').click(function () {
            $('.award-hidden').css('display','none');
        })
        $('.award-hidden .sub-mit').click(function () {
            $('.award-hidden').css('display','none');
        })
        $('.award-hidden form a').each(function () {
            $(this).click(function () {
                $(this).siblings().removeClass('active')
                $(this).addClass('active');

            })
        })
        $('.min-con li a').each(function () {
            $(this).click(function () {
                $('.detail-pub').css('display','block');
                $('.detail-pub').html('<div class="popup"><h3>详情</h3><i class="weui-icon-cancel"></i></div>'+'<p>'+$(this).find('.title-p').text()+'</p>'+'<ul>'+$(this).next().html()+'</ul>');
                $('.detail-pub .popup i').click(function () {
                    $('.detail-pub').css('display','none');
                })
                if(($(this).next().find('li').length)%2==0){
                    console.log(1)
                    $('.detail-pub ul li:last-child .circle-sp').css('background-image','url(../../images/system/last-2.png)');
                }else if(($(this).next().find('li').length)%2==1){
                    $('.detail-pub ul li:last-child .circle-sp').css('background-image','url(../../images/system/last-1.png)');
                    console.log(2)
                }
            })
        });

        $('.kh_submit').click(function(){
            var toke = $('input[name=_token]').val();
            var cid = $('.kaohe_rp.active').attr('data-id');
            var uid = $('select[name=tuid]').val();
            var reason= $('textarea[name=reason]').val();
            var clas = $('select[name=class]').val();
            $.ajax({
                'url': '/user/reward/reward-punish?_token='+toke+'&uid='+uid+'&catid='+cid,
                'type': 'POST',
                'data': {'reason':reason,'grade':clas},
                error: function (request) {
                    console.log("error");
                },
                success: function (data) {
                    if (data.status == 'success') {
                        alert('评价提交成功');
                        setTimeout(function(){ window.location.reload(); }, 1000);
                    } else {
                        //$.toast(data.msg,'forbidden');
                        console.log("error");
                    }
                },
            });
        });

    });

</script>
</body>
</html>